<template>
  <div class="main">
    <div class="title">
      <div class="title-font">数据生成</div>
      <div class="back">
        <div @click="goBack"><i class="el-icon-back"></i>返回</div>
      </div>
    </div>
    <el-container>
      <el-aside width="300px">
        <a-side @changeTable="changeTable" :tables="tables"></a-side>
      </el-aside>
      <el-main>
        <other-side ref="OtherSide" :tableName="tableName" :dbInfo="dbInfo" :tables="tables"></other-side>
      </el-main>
    </el-container>
    <!--    <div class="content">-->
    <!--      <div class="left">-->
    <!--        <a-side @changeTable="changeTable" :tables="tables"></a-side>-->
    <!--      </div>-->
    <!--      <div class="right">-->
    <!--        <other-side ref="OtherSide" :tableName="tableName" :dbInfo="dbInfo" :tables="tables"></other-side>-->
    <!--      </div>-->
    <!--    </div>-->
  </div>
</template>

<script>
import ASide from "./aSide"
import OtherSide from "./otherSide"

export default {
  name: "index",
  components: {ASide, OtherSide},
  data() {
    return {
      tableName: "",
      tables: [],
      dbInfo: {}
    }
  },
  created() {
    if (JSON.stringify(this.$route.params) === "{}") {
      this.tables = JSON.parse(sessionStorage.getItem("tables"))
      this.dbInfo = JSON.parse(sessionStorage.getItem("dbInfo"))
    } else {
      this.tables = this.$route.params.tables
      this.dbInfo = this.$route.params.dbInfo
    }
  },
  methods: {
    //返回上一页
    goBack() {
      this.$router.push({"path": "/testTool/dataSource"})
    },
    /*切换表*/
    changeTable(tableName) {
      this.tableName = tableName
      this.$refs.OtherSide.clickTableName(tableName);
    }
  }
}
</script>

<style scoped lang="scss">
.main {
  height: calc(100vh - 110px);
  background: #ffffff;
  margin: 20px;
  //overflow: hidden;
}

.title {
  height: 50px;
  padding: 0 20px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 0 0 auto;
}

.title-font {
  font-size: 20px;
  color: #333;
  line-height: 1;
  font-weight: 700;
}

.back {
  position: relative;
  font-size: 14px;
  color: #0044f0;
  line-height: 1;
  cursor: pointer;
}

.content {
  display: flex;

  .left {
    width: 300px;
    border-right: 1px solid #ddd;
  }

  .right {
    flex: 1;
    padding: 20px;
  }
}
</style>
